﻿// -----------------------------------------------------------------------
// <copyright company="Christoph van der Fecht - VDsoft">
// Copyright (C) Christoph van der Fecht - VDsoft - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited,
// unless it is communicated and authorized by the copyright owner.
// </copyright>
// -----------------------------------------------------------------------

using SeriesManager.Model;
using System;

namespace SeriesManager.ViewModel.Options
{
	/// <summary>
	/// Stores the options for the banner settings.
	/// </summary>
	public class BannerSettingsViewModel : OptionsPart
	{
		/// <summary>
		/// The currently selected naming convention.
		/// </summary>
		private NamingConventions selectedNamingConvention = NamingConventions.WindowsMediaCenter;

		/// <summary>
		/// Initializes a new instance of the <see cref="BannerSettingsViewModel"/> class.
		/// </summary>
		public BannerSettingsViewModel()
		{
			if (this.IsInDesignMode)
			{
				this.SelectedNamingConvention = NamingConventions.WindowsMediaCenter;
			}
			else
			{
				this.LoadSettings();
			}
		}

		/// <summary>
		/// Gets or sets the currently selected naming convention.
		/// </summary>
		public NamingConventions SelectedNamingConvention
		{
			get
			{
				return this.selectedNamingConvention;
			}

			set
			{
				if (value == this.selectedNamingConvention)
				{
					return;
				}

				this.selectedNamingConvention = value;
				this.RaisePropertyChanged();
			}
		}	

		/// <summary>
		/// Saves the settings for the banner options.
		/// </summary>
		public override void SaveSettings()
		{
			Properties.Settings.Default.NamingConventions = this.selectedNamingConvention.ToString();
		}

		/// <summary>
		/// Loads all settings for the banner options.
		/// </summary>
		public override void LoadSettings()
		{
			this.SelectedNamingConvention = (NamingConventions)Enum.Parse(typeof(NamingConventions), Properties.Settings.Default.NamingConventions);
		}
	}
}
